﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Nirvana
{
	/// <summary>
	/// 场景CG雾效参数设置
	/// </summary>
	public sealed class CGCameraFog : MonoBehaviour
	{
		[SerializeField]
		private Color fogColor;
		[SerializeField]
		private FogMode fogMode = FogMode.Linear;
		[SerializeField]
		private float fogStart,fogEnd;

		private Color oldColor;
		private FogMode oldFogMode;
		private float oldStart;
		private float oldEnd;

		void OnEnable()
        {
			this.oldColor = RenderSettings.fogColor;
			this.oldFogMode = RenderSettings.fogMode;
			this.oldStart = RenderSettings.fogStartDistance;
			this.oldEnd = RenderSettings.fogEndDistance;


			RenderSettings.fogColor = this.fogColor;
			RenderSettings.fogMode = this.fogMode;
			RenderSettings.fogStartDistance = this.fogStart;
			RenderSettings.fogEndDistance = this.fogEnd;

		}

		void OnDisable()
		{
			RenderSettings.fogColor = this.oldColor;
			RenderSettings.fogMode = this.oldFogMode;
			RenderSettings.fogStartDistance = this.oldStart;
			RenderSettings.fogEndDistance = this.oldEnd;
		}

	}
}

